package src.twice;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class Candidate1 {

    Integer len = new Integer("0");

    public int getBallot(String name){
        File file = new File("");
        FileReader fis;
        try{
            if(!file.exists()){
                file.createNewFile();
            }

            fis = new FileReader(file);
            BufferedReader bis = new BufferedReader(fis);
            String str[] = new String[3];
            String size;
            int i = 0;
            while ((size = bis.readLine()) != null){
                str[i] = size.trim();
                if(str[i].startsWith(name)){
                    int length = str[i].indexOf(".");
                    String sub = str[i].substring(length+1,str[i].length());
                    len = Integer.parseInt(sub);
                    continue;
                }
                i++;
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return len;
    }
}
